//login.html

$(document).ready(function(){
	$('.nav li').mouseover(function(){
		$(this).find('ul').show();
	});
	$('.nav li ul').mouseout(function(){
		$(this).hide();
	});
	
    $('#sidebar').mouseout(function(){
        $('.nav li ul').hide();
    })
	
	
})

var loginInit = function(){
	// Checking for CSS 3D transformation support
	$.support.css3d = supportsCSS3D();	
	var formContainer = $('.loginWrapper');	
	// Listening for clicks on the ribbon links
	$('.flip').click(function(e){
		
		// Flipping the forms
		formContainer.toggleClass('flipped');
		
		// If there is no CSS3 3D support, simply
		// hide the login form (exposing the recover one)
		if(!$.support.css3d){
			$('#login').toggle();
		}
		e.preventDefault();
	});
	
	formContainer.find('form').submit(function(e){
		// Preventing form submissions. If you implement
		// a backend, you might want to remove this code
		//e.preventDefault();
	});
	
	
	// A helper function that checks for the 
	// support of the 3D CSS3 transformations.
	function supportsCSS3D() {
		var props = [
			'perspectiveProperty', 'WebkitPerspective', 'MozPerspective'
		], testDom = document.createElement('a');
		  
		for(var i=0; i<props.length; i++){
			if(props[i] in testDom.style){
				return true;
			}
		}
		
		return false;
	}


	
	
	$(".loginPic").hover(
			function() { 
			
			$('.logleft, .logback').animate({left:10, opacity:1},200); 
			$('.logright').animate({right:10, opacity:1},200); },
			
			function() { 
			$('.logleft, .logback').animate({left:0, opacity:0},200);
			$('.logright').animate({right:0, opacity:0},200); }
		);
}


var indexInit = function(){
		var date = new Date();
		var d = date.getDate();
		var m = date.getMonth();
		var y = date.getFullYear();
		
		$('#calendar').fullCalendar({
			header: {
				left: 'prev,next',
				center: 'title',
				right: 'month,agendaWeek,agendaDay'
			},
			editable: true,
			events: [
				{
					title: 'All Day Event',
					start: new Date(y, m, 1)
				},
				{
					title: 'Long Event',
					start: new Date(y, m, d-5),
					end: new Date(y, m, d-2)
				},
				{
					id: 999,
					title: 'Repeating Event',
					start: new Date(y, m, d-3, 16, 0),
					allDay: false
				},
				{
					id: 999,
					title: 'Repeating Event',
					start: new Date(y, m, d+4, 16, 0),
					allDay: false
				},
				{
					title: 'Meeting',
					start: new Date(y, m, d, 10, 30),
					allDay: false
				},
				{
					title: 'Lunch',
					start: new Date(y, m, d, 12, 0),
					end: new Date(y, m, d, 14, 0),
					allDay: false
				},
				{
					title: 'Birthday Party',
					start: new Date(y, m, d+1, 19, 0),
					end: new Date(y, m, d+1, 22, 30),
					allDay: false
				},
				{
					title: 'Click for Google',
					start: new Date(y, m, 28),
					end: new Date(y, m, 29),
					url: 'http://google.com/'
				}
			]
		});

	
}



var settingInit = function(){
	
    $('.checker span').click(function(){
        if($(this).attr('class') == 'checked'){
            $(this).attr('class','');
            $(this).find('checkbox').attr('checked','');
            $(this).parent().next('label').html('不同步');
            $('.formRow').eq(6).slideUp("slow");
        } else{
            $(this).attr('class','checked');
            $(this).find('checkbox').attr('checked','checked');
            $(this).parent().next('label').html('同步');
            $('.formRow').eq(6).slideDown("slow");
        }
    });
    
    
    $('input[name="user_new_password"]').change(function(){
    	if($(this).val().length > 0){
    		$('.formRow').eq(2).slideDown("slow");
    		$('.formRow').eq(4).slideDown("slow");
    	} else {
    		$('.formRow').eq(2).slideUp("slow");
            $('.formRow').eq(4).slideUp("slow");
            $('.formRow').eq(2).find('input').val('');
            $('.formRow').eq(4).find('input').val('');
    	}
    });
    
    //验证
    $('input[name="user_name"]').change(function(){
    })
}